home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / bash / bash_108 / bash-108.zoo / bash-1.08 / mail-shell.orig < prev    next >
Encoding:
Text File  |  1990-03-12  |  1.2 KB  |  56 lines

  1. #!/usr/gnu/bin/bash
  2. #
  3. #  Mail the uuencoded files to USER.
  4. #
  5.  
  6. UUENCODED_DIR=uuencoded
  7.  
  8. if [ ! -d $UUENCODED_DIR ]; then
  9.   if make mailable; then :; else
  10.     echo "Cannot make the shell mailable."
  11.     exit
  12.   fi
  13. fi
  14.  
  15. if [ "$1" = "" ]; then
  16.   echo "Usage:  mail-shell <user>"
  17.   exit
  18. fi
  19.  
  20. count () { echo $#; }
  21. files_to_send=$(count $UUENCODED_DIR/*.uu.*)
  22. files_sent=1
  23.  
  24. if [ ! -f $UUENCODED_DIR/inform ]; then
  25.   if [ -f inform ]; then
  26.      cat inform > $UUENCODED_DIR/inform
  27.   else
  28.      echo "No other information forthcoming.  Complain to bfox!" > $UUENCODED_DIR/inform
  29.   fi
  30.   echo "Here is a directory listing of the files to be sent." >>$UUENCODED_DIR/inform
  31.   (cd $UUENCODED_DIR; ls -l *.uu.* >> inform)
  32. fi
  33.  
  34. for recipient in $*; do
  35.   echo -n "Mailing $recipient information file..."
  36.   cat $UUENCODED_DIR/inform |
  37.     Mail -s "Here comes bash.  Expect $files_to_send files." $recipient
  38.   echo "done."
  39. done
  40.  
  41. for i in $UUENCODED_DIR/*.uu.*; do
  42.   mailfile=$(basename $i)
  43.   for recipient in $*; do
  44.      echo -n "Mailing $mailfile to $recipient..."
  45.      cat $i |
  46.         Mail -s \
  47.     "($files_sent of $files_to_send) Please save this in $mailfile" \
  48.     $recipient
  49.      echo "done."
  50.   done
  51.   files_sent=(expr $files_sent + 1)
  52. done
  53.  
  54. echo "Done mailing the shell to $*."
  55.  
  56.